import time
from appium import webdriver


desired_caps = {
    'platformName': 'Android',
    'platformVersion': '8.1.0',
    'deviceName': '192.168.18.5:5555',
    # 'appPackage': 'com.android.settings',
    # 'appPackage': 'com.lenovocloud.filez',
#     'appActivity': '.MainSettings',
#     'appActivity': 'com.lenovodata.controller.activity.AppStart',
    # 'appWaitActivity': 'com.yunos.tvtaobao/.splashscreen.activity.StartActivity',
    'noReset': True,
}

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# btn_username = driver.find_element_by_id('com.lenovocloud.filez:id/btn_login_fastauth')
# btn_username.click()
time.sleep(2)
text_username = driver.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[4]/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.EditText')
text_username.set_value('frh99@test.com')
time.sleep(2)
text_password = driver.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[4]/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.RelativeLayout[1]/android.widget.EditText')
text_password.set_value('qwe123')
# driver.install_app(r'C:\Users\FRH\Desktop\zBox.apk')

time.sleep(2)
btn_username = driver.find_element_by_id('com.lenovocloud.filez:id/btn_login')
btn_username.click()

time.sleep(5)
print(driver.current_package)
print(driver.current_activity)

# time.sleep(5)

driver.quit()
